//存在一个bug
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
class BugTemplate {
public:
    virtual void FixTest() = 0;
};
class VectorBug :public BugTemplate
{
public:
    VectorBug() {}
    ~VectorBug() {}
    virtual void FixTest()
    {
        std::vector<int> vec = { 1,2,3,4,5,6,7,8,9 };
        std::cout << "正确使用迭代器删除程序前三个数值,使程序不崩溃" << std::endl;
        std::vector<int>::iterator it = vec.begin();
        for (int i = 0; i < 3; i++)
        {
            vec.erase(it);
        }
        for (it = vec.begin(); it != vec.end(); it++)
        {
            std::cout << *it << " ";
        }

    }
};
//修复bug 使程序正常运作
int main()
{
    /*{
        ClassBug bug;
        bug.FixTest();
    }*/
    /*{
        CopyBug bug;
        bug.FixTest();
    }*/
    {
        VectorBug bug;
        bug.FixTest();
    }
    return 0;
}
